"""
@filename: posts.py
@project: flask_project
@author: wlf
@time: 2022-09-06
帖子/文章表
"""
from model import db
import datetime


class Posts(db.Model):
    __tablename__ = "posts"  # 映射的数据库，不写默认是类名
    id = db.Column(db.Integer, primary_key=True, autoincrement=True)
    user_id = db.Column(db.Integer, db.ForeignKey("user.id"))
    school_id = db.Column(db.Integer, db.ForeignKey("school.id"))
    classify = db.Column(db.Enum("情感", "拼车", "寻物and招领", "闲置品"), nullable=False)
    content = db.Column(db.Text, nullable=False)
    picture = db.Column(db.String(512), nullable=False)     # 存放图片路径
    audit = db.Column(db.Integer, nullable=False)
    recommend = db.Column(db.Integer, nullable=False)
    delete = db.Column(db.Integer, nullable=False)

    CreatedAt = db.Column(db.DateTime, default=datetime.datetime.now())
    UpdatedAt = db.Column(db.DateTime, default=None, onupdate=datetime.datetime.now())

